package com.zjdiepu.www.manage.api.base;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.core.ApiResponse;
import com.zjdiepu.www.base.core.PageVo;
import com.zjdiepu.www.common.util.CollectionInitUtil;
import com.zjdiepu.www.ibiz.base.IClientUseCountService;
import com.zjdiepu.www.model.base.dto.OtherAttachments;
import com.zjdiepu.www.model.base.ext.ClientTypeExt;
import com.zjdiepu.www.model.base.vo.ClientTypeVo;

@RestController
@RequestMapping(value= "ClientUseCountContronller", produces="application/json;charset=UTF-8")
@Api(tags = {"客户端使用情况统计"}, produces="application/json;charset=UTF-8")
public class ClientUseCountContronller extends BaseController{

	@Resource
	private IClientUseCountService clientUseCountService;
	
	
	@ApiOperation(value = "客户端使用情况统计", response = OtherAttachments.class, httpMethod="POST", tags={"新增"})
    @RequestMapping(value = "countClient", method = RequestMethod.POST)
	public ApiResponse countClient(@ModelAttribute ClientTypeExt clientTypeExt){
		clientTypeExt.notDeleted();
        PageVo page = getPage(clientTypeExt);
        int records = clientUseCountService.countByExt(clientTypeExt);
        page.setRecords(records);
        if (records > 0) {
            List<ClientTypeVo> dpBaseDataDictionaries = clientUseCountService.selectByExt(clientTypeExt);
            page.setRows(dpBaseDataDictionaries);
        } else {
            page.setRows(CollectionInitUtil.emptyList());
        }
		
		return ApiResponse.success(page);
	}
}
